# app/config.py
import os
from pydantic import Field
from pydantic.config import ConfigDict
from pydantic import BaseModel

class Settings(BaseModel):
    # 配置类
    model_config = ConfigDict(env_file=".env", extra="ignore")

    # 服务器设置
    HOST: str = Field(default="0.0.0.0", env="HOST")
    PORT: int = Field(default=8000, env="PORT")

    # 应用设置
    APP_NAME: str = "ESP-AI ASR API"
    APP_DESCRIPTION: str = "语音识别 API 服务"
    API_PREFIX: str = "/api/v1"

    # Funasr API密钥
    API_KEY: str = Field(default="123456", env="API_KEY")
    
    # Eage TTS API密钥
    EAGE_TTS_API_KEY: str = Field(default="123456", env="EAGE_TTS_API_KEY")
    
    # ASR模型设置
    MODEL_DIR: str = Field(
        default="/home/zhuxiaohuan/桌面/Esp-Ai-Plugin/app/models/SenseVoiceSmall", 
        env="ASR_MODEL_DIR"
    )
    USE_GPU: bool = Field(default=False, env="USE_GPU")
    
    @property
    def DEVICE(self) -> str:
        return "cuda:0" if self.USE_GPU else "cpu"
    
    # 日志设置
    LOG_LEVEL: str = Field(default="INFO", env="LOG_LEVEL")

# 创建设置实例
settings = Settings()